package com.htc.callcare.viewcontroller;

import java.util.ArrayList;

import com.htc.callcare.R;
import com.htc.callcare.adapter.RecordDetailAdapter;
import com.htc.callcare.model.DetailViewModel;
import com.htc.callcare.model.recordModel;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;

public class Record_Detail_View extends LinearLayout{

	Button close;
	ListView listDetail;
	recordModel model;
	ArrayList<DetailViewModel> models;
	RecordDetailAdapter adapter;
	Context context;
	String contact_name;
	public Record_Detail_View(Context context) {
		super(context);
		
		this.context = context;
		LayoutInflater.from(context).inflate(R.layout.record_detail, this, true);
		close = (Button) findViewById(R.id.record_detail_close);
		listDetail = (ListView) findViewById(R.id.record_detail_list);
		close.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Record_Detail_View.this.setVisibility(GONE);		
			}
		});
		
		
	}
	private void initLisview() {
		models = new ArrayList<DetailViewModel>();
		models.add(new DetailViewModel(context.getString(R.string.call_number), this.contact_name));
		models.add(new DetailViewModel(context.getString(R.string.call_time), model.getCallTime()));
		models.add(new DetailViewModel(context.getString(R.string.call_date), model.getCallDay()));
		models.add(new DetailViewModel("Note", model.getNote()));
		models.add(new DetailViewModel("Source", model.getFileUri()));
		adapter = new RecordDetailAdapter(models, context);
		listDetail.setAdapter(adapter);
	}
	public void setProcessModel(recordModel processModel, String contact_name) {
		// TODO Auto-generated method stub
		this.model = processModel;
		this.contact_name = contact_name;
		initLisview();
	}
	

}
